<template>
  <el-drawer
    :title="dataForm.checkList.checkTypeId | titleFilter"
    :visible.sync="visible"
    :before-close="handleClose"
    :size="size">

    <el-col :span="22" :offset="1">
      <el-row>
        <el-button
          v-if="returnBtn"
          type="danger"
          class="pan-btn danger-btn"
          @click="showReturn"
          size="mini">
          退 回
        </el-button>
        <el-button
          v-if="cancelBtn"
          type="danger"
          class="pan-btn danger-btn"
          @click="cancel"
          size="mini">
          作 废
        </el-button>
        <el-button
          v-if="printBtn"
          type="danger"
          class="pan-btn danger-btn"
          @click="print"
          size="mini">
          打 印
        </el-button>
        <el-button
          v-if="recallBtn"
          type="danger"
          class="pan-btn danger-btn"
          @click="recall"
          size="mini">
          撤回结论
        </el-button>
        <el-button
          v-if="changeStandardBtn"
          type="danger"
          class="pan-btn danger-btn"
          @click="changeStandard"
          size="mini">
          修改标准
        </el-button>
        <el-button
          v-if="recallPassBtn"
          type="danger"
          class="pan-btn danger-btn"
          @click="recallPass"
          size="mini">
          撤回放行
        </el-button>
        <el-button
          v-if="showStandardBtn"
          type="info"
          class="pan-btn info-btn"
          @click="showStandardDrawer"
          size="mini">
          查看项目
        </el-button>
        <template v-if="true">
          <el-button
            v-if="!isUpdateMode"
            type="danger"
            class="pan-btn danger-btn"
            @click="updateMode"
            size="mini">
            修改信息
          </el-button>
          <el-button
            v-else
            type="success"
            class="pan-btn success-btn"
            @click="updateModeExit"
            size="mini">
            退出修改
          </el-button>
        </template>
      </el-row>

      <el-form ref="dataForm" :model="dataForm" label-width="120px" size="small">

        <div>
          <!-- 固有显示内容 -->
          <el-form-item>
            <span slot="label">编&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:</span>
            {{ dataForm.checkList.checkId }}
          </el-form-item>

          <el-form-item label="物料名称:">
            {{ dataForm.checkList.productName }}
          </el-form-item>

          <el-form-item label="GMP编码:">
            {{ dataForm.checkList.productGmp }}
          </el-form-item>

          <el-form-item label="货品规格:" v-if="dataForm.checkList.productSpec != null && dataForm.checkList.productSpec != ''">
            <span v-html="dataForm.checkList.productSpec"></span>
          </el-form-item>

          <el-form-item label="包装规格:" v-if="dataForm.checkList.productPackSpec != null && dataForm.checkList.productPackSpec != ''">
            <template v-if="c">
              <el-select
                v-if="isUpdateMode && zcProductPackSpecInput"
                v-model="dataForm.checkList.productPackSpec"
                @change="setListContent('product_pack_spec', dataForm.checkList.productPackSpec, '包装规格', null, null, 'zcProductPackSpecInput')"
                style="width: 95%">
                <el-option
                  v-for="item in zcInfo.productPackSpecList"
                  :key="item.productPackSpecId"
                  :label="item.productPackSpec"
                  :value="item.productPackSpec">
                </el-option>
              </el-select>
              <div
                v-else
                :class="{updatemode:isUpdateMode}"
                @click="openSet2('zcProductPackSpecInput')"
                v-html="dataForm.checkList.productPackSpec" />
            </template>
            <template v-else>
              <el-input
                v-if="isUpdateMode && yfbProductPackSpecInput"
                v-model="dataForm.checkList.productPackSpec"
                @blur="yfbProductPackSpecInput = false"
                @change="setListContent('product_pack_spec', dataForm.checkList.productPackSpec, '包装规格', null, null, 'yfbProductPackSpecInput')"
                style="width: 95%" />
              <div
                v-else
                :class="{updatemode:isUpdateMode}"
                @click="openSet2('yfbProductPackSpecInput')"
                v-html="dataForm.checkList.productPackSpec" />
            </template>
          </el-form-item>

          <el-form-item label="物料编码:" v-if="yfb">
            <el-input
              v-if="isUpdateMode && yfbBatchNumInput"
              v-model="dataForm.checkList.batchNum"
              @blur="yfbBatchNumInput = false"
              @change="setListContent('batch_num', dataForm.checkList.batchNum, '物料编码', 'batch_num_prefix', dataForm.checkList.batchNum, yfbBatchNumInput)"
              style="width: 95%" />
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet2('yfbBatchNumInput')"
              v-html="dataForm.checkList.batchNum" />
          </el-form-item>

          <el-form-item v-if="zc || wk || ys">
            <span slot="label">批&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:</span>
            {{ dataForm.checkList.batchNum }}
          </el-form-item>
        </div>
        <div v-if="yfb">
          <el-form-item label="原厂批号:">
            <el-input
              v-if="isUpdateMode && originalBatchInput"
              v-model="dataForm.yfbList.originalBatch"
              @blur="originalBatchInput = false"
              @change="setYfbContent('original_batch', dataForm.yfbList.originalBatch, '原厂批号')"
              style="width: 95%" />
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('original_batch')"
              v-html="dataForm.yfbList.originalBatch" />
          </el-form-item>
 <!-- @change="setYfbContent('gross_quantity', dataForm.yfbList.grossQuantity, '接收数量')" -->
 <!-- @change="setYfbContentAndId('gross_unit_name', dataForm.yfbList.grossUnitName, '接收数量单位', baseInfo.unitList, 'unitName')" -->
          <el-form-item label="请验数量:">
            <!--           <el-form-item label="接收数量:"> -->
            <el-input
              v-if="isUpdateMode && grossQuantityInput"
              v-model="dataForm.yfbList.grossQuantity"
              @blur="grossQuantityInput = false"
              @change="setYfbContent('gross_quantity', dataForm.yfbList.grossQuantity, '请验数量')"
              style="width: 95%">
              <el-select
                v-model="dataForm.yfbList.grossUnitName"
                @change="setYfbContentAndId('gross_unit_name', dataForm.yfbList.grossUnitName, '请验数量单位', baseInfo.unitList, 'unitName')"
                slot="append" placeholder="单位" style="width: 100px">
                <el-option v-for="item in baseInfo.unitList" :key="item.unitId" :label="item.unitName" :value="item.unitName" />
              </el-select>
            </el-input>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('gross_quantity')"
              v-html="dataForm.yfbList.grossQuantity + ' ' + dataForm.yfbList.grossUnitName" />
          </el-form-item>

          <el-form-item>
            <span slot="label">件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数:</span>
            <el-input
              v-if="isUpdateMode && grossPieceInput"
              v-model="dataForm.yfbList.grossPiece"
              @blur="grossPieceInput = false"
              @change="setYfbContent('gross_piece', dataForm.yfbList.grossPiece, '件数')"
              style="width: 95%">
              <template slot="append">{{dataForm.yfbList.pleaseUnitName == null?'件':dataForm.yfbList.pleaseUnitName}}</template>
            </el-input>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('gross_piece')"
              v-html="dataForm.yfbList.grossPiece + ' '+(dataForm.yfbList.pleaseUnitName == null?'件':dataForm.yfbList.pleaseUnitName)" />
          </el-form-item>

          <el-form-item v-if="dataForm.yfbList.deliveryAndBuyQuantity != null && dataForm.yfbList.deliveryAndBuyQuantity != ''" label="送货数量:">
            <el-input
              v-if="isUpdateMode && deliveryAndBuyQuantityInput"
              v-model="dataForm.yfbList.deliveryAndBuyQuantity"
              @blur="deliveryAndBuyQuantityInput = false"
              @change="setYfbContent('delivery_and_buy_quantity', dataForm.yfbList.deliveryAndBuyQuantity, '送货数量')"
              style="width: 95%">
              <el-select
                v-model="dataForm.yfbList.deliveryAndBuyUnitName"
                @change="setYfbContentAndId('delivery_and_buy_unit_name', dataForm.yfbList.deliveryAndBuyUnitName, '送货数量单位', baseInfo.unitList, 'unitName')"
                slot="append" placeholder="单位" style="width: 100px">
                <el-option v-for="item in baseInfo.unitList" :key="item.unitId" :label="item.unitName" :value="item.unitName" />
              </el-select>
            </el-input>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('delivery_and_buy_quantity')"
              v-html="dataForm.yfbList.deliveryAndBuyQuantity + ' ' + dataForm.yfbList.deliveryAndBuyUnitName" />
          </el-form-item>

          <el-form-item>
            <span slot="label">供&nbsp;&nbsp;应&nbsp;&nbsp;商:</span>
            <el-select
              v-if="isUpdateMode && supplierNameInput"
              v-model="dataForm.yfbList.supplierName"
              @change="setYfbContentAndId('supplier_name', dataForm.yfbList.supplierName, '供应商', yfbInfo.supplierList, 'supplierName')"
              filterable
              remote
              reserve-keyword
              :remote-method="searchSupplier"
              style="width: 95%">
              <el-option
                v-for="item in yfbInfo.supplierList"
                :key="item.supplierId"
                :label="item.supplierName"
                :value="item.supplierName">
              </el-option>
            </el-select>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('supplier_name')"
              v-html="dataForm.yfbList.supplierName" />
          </el-form-item>

          <el-form-item label="供应商物料名称:">
                {{dataForm.yfbList.originalProductName == null?'':dataForm.yfbList.originalProductName}}
          </el-form-item>

          <el-form-item label="供应商物料规格:">
            {{dataForm.yfbList.originalProductSpec == null?'':dataForm.yfbList.originalProductSpec}}
          </el-form-item>

          <el-form-item v-if="dataForm.yfbList.productionDate != null" label="生产日期:">
            <template v-if="isUpdateMode && yfbProductionDateInput">
              <el-date-picker
                v-model="dataForm.yfbList.productionDate"
                @blur="yfbProductionDateInput = false"
                @change="setYfbContent('production_date', dataForm.yfbList.productionDate, '生产日期', null, null, 'yfbProductionDateInput')"
                align="right"
                :type="dateTypeFilter(dataForm.yfbList.productionDateUnit)"
                style="width: 80%"
                :format="dateFormatFilter(dataForm.yfbList.productionDateUnit)"
                value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
              <el-tooltip :content="dataForm.yfbList.productionDateUnit == 0 ? '此时精确到日' : '此时精确到月'" placement="top">
                <el-switch
                  v-model="dataForm.yfbList.productionDateUnit"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  @click.native="setYfbContent('production_date_unit', dataForm.yfbList.productionDateUnit, '生产日期精确到月或日的配置')"
                  :active-value="1"
                  :inactive-value="0">
                </el-switch>
              </el-tooltip>
            </template>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet2('yfbProductionDateInput')">
              {{ dataForm.yfbList.productionDate | showTime(dataForm.yfbList.productionDateUnit) }}
            </div>
          </el-form-item>

          <el-form-item v-if="dataForm.yfbList.validityDate != null" label="有效期至:">
            <template v-if="isUpdateMode && yfbValidityDateInput">
              <el-date-picker
                v-model="dataForm.yfbList.validityDate"
                @blur="yfbValidityDateInput = false"
                @change="setYfbContent('validity_date', dataForm.yfbList.validityDate, '有效期至', null, null, 'yfbValidityDateInput')"
                align="right"
                :type="dateTypeFilter(dataForm.yfbList.selectDateUnit)"
                style="width: 80%"
                :format="dateFormatFilter(dataForm.yfbList.selectDateUnit)"
                value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
              <el-tooltip :content="dataForm.yfbList.selectDateUnit == 0 ? '此时精确到日' : '此时精确到月'" placement="top">
                <el-switch
                  v-model="dataForm.yfbList.selectDateUnit"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  @click.native="setYfbContent('select_date_unit', dataForm.yfbList.selectDateUnit, '有效期(或复验期)精确到月或日的配置')"
                  :active-value="1"
                  :inactive-value="0">
                </el-switch>
              </el-tooltip>
            </template>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet2('yfbValidityDateInput')">
              {{ dataForm.yfbList.validityDate | showTime(dataForm.yfbList.selectDateUnit) }}
            </div>
          </el-form-item>

          <el-form-item v-if="dataForm.yfbList.reinspectDate != null">
            <span slot="label">复&nbsp;&nbsp;验&nbsp;&nbsp;期:</span>
            <template v-if="isUpdateMode && reinspectDateInput">
              <el-date-picker
                v-model="dataForm.yfbList.reinspectDate"
                @blur="reinspectDateInput = false"
                @change="setYfbContent('reinspect_date', dataForm.yfbList.reinspectDate, '复验期')"
                align="right"
                :type="dateTypeFilter(dataForm.yfbList.selectDateUnit)"
                style="width: 80%"
                :format="dateFormatFilter(dataForm.yfbList.selectDateUnit)"
                value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
              <el-tooltip :content="dataForm.yfbList.selectDateUnit == 0 ? '此时精确到日' : '此时精确到月'" placement="top">
                <el-switch
                  v-model="dataForm.yfbList.selectDateUnit"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  @click.native="setYfbContent('select_date_unit', dataForm.yfbList.selectDateUnit, '有效期(或复验期)精确到月或日的配置')"
                  :active-value="1"
                  :inactive-value="0">
                </el-switch>
              </el-tooltip>
            </template>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('reinspect_date')">
              {{ dataForm.yfbList.reinspectDate | showTime(dataForm.yfbList.selectDateUnit) }}
            </div>
          </el-form-item>

          <el-form-item label="生产企业:">
            <el-select
              v-if="isUpdateMode && manufacturerNameInput"
              v-model="dataForm.yfbList.manufacturerName"
              @change="setYfbContentAndId('manufacturer_name', dataForm.yfbList.manufacturerName, '生产企业', yfbInfo.manufacturerList, 'manufacturerName')"
              filterable
              remote
              reserve-keyword
              :remote-method="searchManufacturer"
              style="width: 95%">
              <el-option
                v-for="item in yfbInfo.manufacturerList"
                :key="item.manufacturerId"
                :label="item.manufacturerName"
                :value="item.manufacturerName">
              </el-option>
            </el-select>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('manufacturer_name')"
              v-html="dataForm.yfbList.manufacturerName" />
          </el-form-item>
        </div>
        <div v-if="zc">
          <el-form-item>
            <span slot="label">批&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量:</span>
            <el-input
              v-if="isUpdateMode && batchQuantityInput"
              v-model="dataForm.zcList.batchQuantity"
              @blur="batchQuantityInput = false"
              @change="setZcContent('batch_quantity', dataForm.zcList.batchQuantity, '批量')"
              style="width: 95%">
              <el-select
                v-model="dataForm.zcList.batchUnitName"
                @change="setZcContentAndId('batch_unit_name', dataForm.zcList.batchUnitName, '批量单位', baseInfo.unitList, 'unitName')"
                slot="append" placeholder="单位" style="width: 100px">
                <el-option v-for="item in baseInfo.unitList" :key="item.unitId" :label="item.unitName" :value="item.unitName" />
              </el-select>
            </el-input>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('batch_quantity')"
              v-html="dataForm.zcList.batchQuantity + ' ' + dataForm.zcList.batchUnitName" />
          </el-form-item>

          <el-form-item v-if="!z && dataForm.zcList.productionQuantity != null" label="产成品量:">
            <el-input
              v-if="isUpdateMode && productionQuantityInput"
              v-model="dataForm.zcList.productionQuantity"
              @blur="productionQuantityInput = false"
              @change="setZcContent('production_quantity', dataForm.zcList.productionQuantity, '产成品量')"
              style="width: 95%">
              <el-select
                v-model="dataForm.zcList.productionUnitName"
                @change="setZcContentAndId('production_unit_name', dataForm.zcList.productionUnitName, '产成品量单位', baseInfo.unitList, 'unitName')"
                slot="append" placeholder="单位" style="width: 100px">
                <el-option v-for="item in baseInfo.unitList" :key="item.unitId" :label="item.unitName" :value="item.unitName" />
              </el-select>
            </el-input>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('production_quantity')"
              v-html="dataForm.zcList.productionQuantity + ' ' + dataForm.zcList.productionUnitName" />
          </el-form-item>

          <el-form-item label="生产工序:">
            <template v-if="c">
              {{ dataForm.zcList.procedureName }}
            </template>
            <template v-else>
              <el-select
                v-if="isUpdateMode && procedureNameInput"
                v-model="dataForm.zcList.procedureName"
                @change="setZcContentAndId('procedure_name', dataForm.zcList.procedureName, '生产工序', zcInfo.procedureList, 'procedureName')"
                filterable
                style="width: 95%">
                <el-option
                  v-for="item in zcInfo.procedureList"
                  :key="item.procedureId"
                  :label="item.procedureName"
                  :value="item.procedureName">
                </el-option>
              </el-select>
              <div
                v-else
                :class="{updatemode:isUpdateMode}"
                @click="openSet('procedure_name')"
                v-html="dataForm.zcList.procedureName" />
            </template>
          </el-form-item>

          <el-form-item label="生产车间:">
            <el-select
              v-if="isUpdateMode && workshopNameInput"
              v-model="dataForm.zcList.workshopName"
              @change="setZcContentAndId('workshop_name', dataForm.zcList.workshopName, '生产车间', zcInfo.workshopList, 'workshopName')"
              filterable
              style="width: 95%">
              <el-option
                v-for="item in zcInfo.workshopList"
                :key="item.workshopId"
                :label="item.workshopName"
                :value="item.workshopName">
              </el-option>
            </el-select>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet('workshop_name')"
              v-html="dataForm.zcList.workshopName" />
          </el-form-item>

          <el-form-item label="生产日期:">
            <template v-if="isUpdateMode && zcProductionDateInput">
              <el-date-picker
                v-model="dataForm.zcList.productionDate"
                @blur="zcProductionDateInput = false"
                @change="setZcContent('production_date', dataForm.zcList.productionDate, '生产日期', null, null, 'zcProductionDateInput')"
                align="right"
                type="date"
                style="width: 95%"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </template>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet2('zcProductionDateInput')">
              {{ dataForm.zcList.productionDate | changeTime }}
            </div>
          </el-form-item>

          <el-form-item label="有效期至:" v-if="dataForm.zcList.validityDate != null">
            <template v-if="isUpdateMode && zcValidityDateInput">
              <el-date-picker
                v-model="dataForm.zcList.validityDate"
                @blur="zcValidityDateInput = false"
                @change="setZcContent('validity_date', dataForm.zcList.validityDate, '有效期至', null, null, 'zcValidityDateInput')"
                align="right"
                type="date"
                style="width: 95%"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </template>
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet2('zcValidityDateInput')">
              {{ dataForm.zcList.validityDate | changeTime }}
            </div>
          </el-form-item>
        </div>
        <div v-if="wk">
          <el-form-item label="方案编号:">
            <el-link type="primary" @click="goOtherRoute('稳考方案',dataForm.wkList.projectId)">{{ dataForm.wkList.projectId }}</el-link>
          </el-form-item>

          <el-form-item label="计划编号:">
            <el-link type="primary" @click="goOtherRoute('稳考室',dataForm.wkList.planId)">{{ dataForm.wkList.planId }}</el-link>
          </el-form-item>

          <el-form-item label="时间编号:">
            {{ dataForm.wkList.planTimeId }}
          </el-form-item>

          <el-form-item label="考察信息:">
            {{ dataForm.wkList.stabilityModeName + ' ' + dataForm.wkList.timeValue + dataForm.wkList.timeName }}
          </el-form-item>

          <el-form-item label="生产车间:">
            {{ dataForm.wkList.workshopName }}
          </el-form-item>

          <el-form-item label="生产日期:" v-if="dataForm.wkList.productionDate != null">
            {{ dataForm.wkList.productionDate | changeTime }}
          </el-form-item>

          <el-form-item label="有效期至:" v-if="dataForm.wkList.validityDate != null">
            {{ dataForm.wkList.validityDate | changeTime }}
          </el-form-item>
        </div>
        <div v-if="ys">
          <el-form-item label="取样车间:">
            {{ dataForm.ysList.workshopName }}
          </el-form-item>

          <el-form-item label="取样点位:">
            {{ dataForm.ysList.wgInfo }}
          </el-form-item>

          <el-form-item label="车间代号:">
            {{ dataForm.ysList.workshopCode }}
          </el-form-item>

          <el-form-item label="取样容器:">
            {{ dataForm.ysList.packContainerName }}
          </el-form-item>

          <el-form-item label="请验目的:">
            {{ dataForm.ysList.checkPurposeName }}
          </el-form-item>
        </div>

        <div>
          <!-- 固有显示内容 -->
          <!-- 请验信息 -->
          <div>
            <el-form-item label="请验部门:">
              {{ dataForm.checkList.registCheckDepartmentName }}
            </el-form-item>

            <el-form-item>
              <span slot="label">请&nbsp;&nbsp;验&nbsp;&nbsp;人:</span>
              {{ dataForm.checkList.registCheckUserName }}
            </el-form-item>

            <el-form-item label="请验日期:">
              <template v-if="isUpdateMode && registCheckDateInput">
                <el-date-picker
                  v-model="dataForm.checkList.registCheckDate"
                  @blur="registCheckDateInput = false"
                  @change="setListContent('regist_check_date', dataForm.checkList.registCheckDate, '请验日期')"
                  align="right"
                  type="date"
                  style="width: 95%"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd HH:mm:ss">
                </el-date-picker>
              </template>
              <div
                v-else
                :class="{updatemode:isUpdateMode}"
                @click="openSet2('registCheckDateInput')">
                {{ dataForm.checkList.registCheckDate | changeTime }}
              </div>
            </el-form-item>
          </div>

          <!-- 取样信息 -->
          <div v-if="dataForm.checkList.status > 1">
            <el-form-item>
              <span slot="label">取&nbsp;&nbsp;样&nbsp;&nbsp;人:</span>
              {{ dataForm.checkList.getUserName }}
            </el-form-item>

            <el-form-item label="取样日期:">
              {{ dataForm.checkList.getDate | changeTime }}
            </el-form-item>

            <el-form-item>
              <span slot="label">取&nbsp;&nbsp;样&nbsp;&nbsp;量:</span>
              {{ dataForm.checkList.getQuantity + dataForm.checkList.getUnitName }}
              <span v-if="ys">{{ '=> ' + dataForm.ysList.wqInfo }}</span>
            </el-form-item>
          </div>

          <!-- 收样信息 -->
          <div v-if="dataForm.checkList.status > 2">
            <el-form-item>
              <span slot="label">收&nbsp;&nbsp;样&nbsp;&nbsp;人:</span>
              {{ dataForm.checkList.receiveUserName }}
            </el-form-item>

            <el-form-item label="收样日期:">
              {{ dataForm.checkList.receiveDate | changeTime }}
            </el-form-item>
          </div>

          <!-- 分发信息 -->
          <div v-if="dataForm.checkList.status > 3">
            <el-form-item>
              <span slot="label">分&nbsp;&nbsp;发&nbsp;&nbsp;人:</span>
              {{ dataForm.checkList.dispenseUserName }}
            </el-form-item>

            <el-form-item label="分发日期:">
              {{ dataForm.checkList.dispenseDate | changeTime }}
            </el-form-item>

            <div v-if="(dataForm.checkList.status == 4 || dataForm.checkList.status == 5) && dataForm.checkList.groupGetUnitName != null">
              <el-form-item>
                <span slot="label">分&nbsp;&nbsp;发&nbsp;&nbsp;量:</span>
                {{ dataForm.checkList.groupGetQuantity + dataForm.checkList.groupGetUnitName }}
              </el-form-item>
            </div>
          </div>

          <!-- 检验信息 -->
          <div v-if="dataForm.checkList.status > 5">
            <el-form-item>
              <span slot="label">检&nbsp;&nbsp;验&nbsp;&nbsp;组:</span>
              {{ dataForm.checkList.inspectGroupNames }}
            </el-form-item>

            <el-form-item label="检验时间:">
              {{ dataForm.checkList.inspectDate | changeTime }}
            </el-form-item>
          </div>

          <!-- 结论信息 -->
          <div v-if="dataForm.checkList.status > 6">
            <el-form-item>
              <span slot="label">结&nbsp;&nbsp;论&nbsp;&nbsp;人:</span>
              {{ dataForm.checkList.verdictUserName }}
            </el-form-item>

            <el-form-item label="结论时间:">
              {{ dataForm.checkList.verdictDate | changeTime }}
            </el-form-item>
          </div>

          <!-- 报告信息 -->
          <div v-if="dataForm.checkList.reportDate != null">
            <el-form-item>
              <span slot="label">报&nbsp;&nbsp;告&nbsp;&nbsp;人:</span>
              {{ dataForm.checkList.reportUserName }}
            </el-form-item>

            <el-form-item label="报告时间:">
              {{ dataForm.checkList.reportDate | changeTime }}
            </el-form-item>
          </div>

          <!-- 放行信息 -->
          <div v-if="dataForm.checkList.status > 7 && dataForm.checkList.status != 10">
            <el-form-item>
              <span slot="label">放&nbsp;&nbsp;行&nbsp;&nbsp;人:</span>
              {{ dataForm.checkList.passUserName }}
            </el-form-item>

            <el-form-item label="放行时间:">
              {{ dataForm.checkList.passDate | changeTime }}
            </el-form-item>
          </div>

<!--          <el-form-item v-if="dataForm.checkList.remark != null">
            <span slot="label">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</span>
            {{ dataForm.checkList.remark }}
          </el-form-item> -->

          <el-form-item v-if="yfb">
             <span slot="label">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</span>
            <el-input
              v-if="isUpdateMode && yfbReMarkInput"
              v-model="dataForm.checkList.remark"
              @blur="yfbReMarkInput = false"
              @change="setListContent('remark', dataForm.checkList.remark, '备注', null, null, yfbReMarkInput)"
              style="width: 95%" />
            <div
              v-else
              :class="{updatemode:isUpdateMode}"
              @click="openSet2('yfbReMarkInput')"
              v-html="dataForm.checkList.remark" />
          </el-form-item>

          <el-form-item label="请验目的:">
            {{ testWay(dataForm.checkList.isTest) }}
          </el-form-item>

          <el-form-item label="请验项目:" v-if="showStandardBtn">
            {{ dataForm.checkList.isAllTest == 0 ? '全检' : dataForm.itemNames }}
          </el-form-item>
        </div>
      </el-form>

    </el-col>

    <el-dialog
      title="报告日期"
      :visible.sync="printVisible"
      :before-close="closePrint"
      :append-to-body="true"
      width="20%">
      <el-form>
        <el-form-item label="报告日期">
          <el-date-picker
            v-model="grandDataForm.halfReportDate"
            align="right"
            type="date"
            placeholder="选择日期"
            style="width: 100%;"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd HH:mm:ss">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="报告版本:">
          <el-select v-model="grandDataForm.printReportVersion" filterable placeholder="报告版本号" style="width: 100%">
            <el-option
              v-for="v in versions"
              :key="v.checkVersionId"
              :label="v.title"
              :value="v.versionNum">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="第一次结论">
          <el-input type="textarea" placeholder="第一次结论" autosize v-model="grandDataForm.halfVerdict" :clearable="true" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closePrint">取 消</el-button>
        <el-button type="primary" class="pan-btn primary-btn" @click="showReport">确 定</el-button>
      </span>
    </el-dialog>

    <print
      v-if="reportVisible"
      @close="close('reportVisible','refresh')"
      :childDataForm="grandDataForm" />

    <change-standard
      v-if="changeStandardVisible"
      @close="close('changeStandardVisible')"
      :childDataForm="grandDataForm" />

    <el-dialog
      title="退回"
      :visible.sync="returnVisible"
      :before-close="closeReturn"
      :append-to-body="true"
      :close-on-click-modal="false"
      width="50%">
      <el-card>
        <el-form label-position="top">
          <el-form-item label="退回理由">
            <el-input v-model="dataForm.checkReturn.returnReason" type="textarea" :rows="3" />
          </el-form-item>
          <el-form-item label="退回至">
            <el-select v-model="dataForm.checkReturn.toEntity" value-key="status" @change="setToEntity" placeholder="请选择">
              <el-option
                v-for="item in statusList"
                :key="item.status"
                :label="item.name"
                :value="item" />
            </el-select>
            <span>{{ dataForm.checkReturn.toUserName }}</span>
          </el-form-item>
        </el-form>
      </el-card>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeReturn">取 消</el-button>
        <el-button type="primary" :loading="submitingReturn" @click="submitReturn">确 定</el-button>
    	</span>
    </el-dialog>

    <el-drawer
      title="检验项目"
      :visible.sync="standardDrawerVisible"
      :append-to-body="true"
      :before-close="closeStandardDrawer"
      :size="dataForm.currentStatus >= 4 ? '80%' : '60%'">
        <h4 style="margin-left: 16px;">
          {{dataForm.checkList.productName + ' ' + dataForm.standard.insideInspectionStandardNum + (dataForm.standard.nationInspectionStandardNum == null ||  dataForm.standard.nationInspectionStandardNum ==  '' ? '' : ('('+dataForm.standard.nationInspectionStandardNum+')')) }}
          &nbsp;&nbsp;
          <span v-if="editBtn">
            <!-- 编辑 -->
            <i class="el-icon-edit point color-danger" v-if="!editing && !editGrouping" @click="editItem" />
            <!-- 改变小组 -->
            &nbsp;
            <i class="el-icon-user-solid point color-danger" v-if="!editGrouping && !editing" @click="editGroup" />
            <!-- 取消 -->
            <i class="el-icon-close point color-danger" v-if="editing || editGrouping" @click="closeEdit" />
            &nbsp;
            <!-- 确定 -->
            <i class="el-icon-check point color-danger" v-if="editing || editGrouping" @click="updateItem" />
          </span>
          <span v-if="updateBtn">
            <!-- 增加 -->
            <i class="el-icon-circle-plus point color-danger" @click="addItem" />
            &nbsp;
            <!-- 删除 -->
            <i class="el-icon-remove point color-danger" @click="deleteItem" />
          </span>
        </h4>
        <el-table
        	:data="allItems"
          ref="dataTable"
          fit
          highlight-current-row
          @row-click="handleCurrentChange"
          @selection-change="selectionChange"
        	style="width: 100%">
          <el-table-column
            v-if="editing"
            type="selection"
            header-align="center"
            align="center"
            width="50">
          </el-table-column>
          <el-table-column
          	prop="inspectionCategoryName"
          	header-align="center"
          	align="center"
          	label="检验项分类"
            width="100">
          </el-table-column>
          <el-table-column
          	prop="inspectionItemName"
          	header-align="center"
          	align="center"
          	label="检验项名称"
            width="200">
          </el-table-column>
          <el-table-column
          	prop="printItemName"
          	header-align="center"
          	align="center"
          	label="打印名称"
            width="200">
          </el-table-column>
          <el-table-column
          	prop="inspectionGroupName"
          	header-align="center"
          	align="center"
          	label="所属组别"
            width="130">
            <template slot-scope="{row}">
              <el-select v-if="editGrouping" v-model="row.inspectionGroupName" @change="changeItemGroup(row)" placeholder="所属小组" size="small">
                <el-option
                  v-for="group in groupList"
                  :key="group.inspectionGroupId"
                  :label="group.inspectionGroupName"
                  :value="group.inspectionGroupName">
                </el-option>
              </el-select>
              <span v-else>{{ row.inspectionGroupName }}</span>
            </template>
          </el-table-column>
          <el-table-column
          	prop="insideInspectionItemValue"
          	header-align="center"
          	align="center"
          	label="内控标准值">
            <template slot-scope="{row}">
              <span v-html='row.insideInspectionItemValue'></span>
            </template>
          </el-table-column>
          <el-table-column
            v-if="dataForm.currentStatus >= 4"
            prop="itemConclusionMerge"
            header-align="center"
            align="center"
            label="检验结果">
            <template slot-scope="{row}">
              <span v-html='row.itemConclusionMerge'></span>
            </template>
          </el-table-column>
          <el-table-column
            v-if="dataForm.currentStatus >= 4"
            prop="itemVerdict"
            header-align="center"
            align="center"
            label="结果判断"
            width="100">
            <template slot-scope="{row}">
              {{ row.itemVerdict == 0 ? '符合规定' : row.itemVerdict == 1 ? '不符合规定' : null }}
            </template>
          </el-table-column>
          <el-table-column
            v-if="dataForm.currentStatus >= 4"
            prop="inspectionUserName"
            header-align="center"
            align="center"
            label="检验人"
            width="100">
          </el-table-column>
          <el-table-column
            v-if="dataForm.currentStatus >= 4"
            prop="startTime"
            header-align="center"
            align="center"
            label="检验开始时间"
            width="110">
            <template slot-scope="{row}">
              {{ row.startTime | changeTime }}
            </template>
          </el-table-column>
          <el-table-column
            v-if="dataForm.currentStatus >= 4"
            prop="endTime"
            header-align="center"
            align="center"
            label="检验结束时间"
            width="110">
            <template slot-scope="{row}">
              {{ row.endTime | changeTime }}
            </template>
          </el-table-column>
        </el-table>
      </el-drawer>

      <el-dialog
        title="增加列表"
        :visible.sync="addItemsVisible"
        :before-close="closeAddItems"
        :append-to-body="true"
        :close-on-click-modal="false"
        width="50%">
        <el-table
        	:data="addItems"
          fit
          highlight-current-row
          @selection-change="selectionChange"
        	style="width: 100%">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            width="50">
          </el-table-column>
          <el-table-column
          	prop="inspectionItemId"
          	header-align="center"
          	align="center"
          	label="编号"
            width="100">
          </el-table-column>
          <el-table-column
          	prop="inspectionCategoryName"
          	header-align="center"
          	align="center"
          	label="检验项分类"
            width="100">
          </el-table-column>
          <el-table-column
          	prop="inspectionItemName"
          	header-align="center"
          	align="center"
          	label="检验项名称"
            width="200">
          </el-table-column>
          <el-table-column
          	prop="inspectionGroupName"
          	header-align="center"
          	align="center"
          	label="所属组别"
            width="100">
          </el-table-column>
          <el-table-column
          	prop="insideInspectionItemValue"
          	header-align="center"
          	align="center"
          	label="内控标准值">
            <template slot-scope="{row}">
              <span v-html='row.insideInspectionItemValue'></span>
            </template>
          </el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer">
          <el-button @click="closeAddItems">取 消</el-button>
          <el-button type="primary" :loading="submitAdding" @click="submitAddItems">添 加</el-button>
        </span>
      </el-dialog>

      <el-dialog
        title="删除列表"
        :visible.sync="deleteItemsVisible"
        :before-close="closeDeleteItems"
        :append-to-body="true"
        :close-on-click-modal="false"
        width="50%">
        <el-table
        	:data="deleteItems"
          fit
          highlight-current-row
          @selection-change="selectionChange"
        	style="width: 100%">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            width="50">
          </el-table-column>
          <el-table-column
          	prop="checkItemId"
          	header-align="center"
          	align="center"
          	label="编号"
            width="100">
          </el-table-column>
          <el-table-column
          	prop="inspectionCategoryName"
          	header-align="center"
          	align="center"
          	label="检验项分类"
            width="100">
          </el-table-column>
          <el-table-column
          	prop="inspectionItemName"
          	header-align="center"
          	align="center"
          	label="检验项名称"
            width="200">
          </el-table-column>
          <el-table-column
          	prop="inspectionGroupName"
          	header-align="center"
          	align="center"
          	label="所属组别"
            width="100">
          </el-table-column>
          <el-table-column
          	prop="insideInspectionItemValue"
          	header-align="center"
          	align="center"
          	label="内控标准值">
            <template slot-scope="{row}">
              <span v-html='row.insideInspectionItemValue'></span>
            </template>
          </el-table-column>
          <el-table-column
            prop="itemStatus"
            header-align="center"
            align="center"
            label="保存状态"
            width="80">
            <template slot-scope="{row}">
              <i v-if="row.itemStatus == 2" style="color: #67C23A;font-size: 25px;" class="el-icon-check"></i>
              <i v-else style="color: #F56C6C;font-size: 25px;" class="el-icon-close"></i>
            </template>
          </el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer">
          <el-button @click="closeDeleteItems">取 消</el-button>
          <el-button type="primary" :loading="submitDeleteing" @click="submitDeleteItems">删 除</el-button>
        </span>
      </el-dialog>

      <el-dialog
        title="确定分发量"
        :visible.sync="dispenseVisible"
        :before-close="closeDispense"
        :append-to-body="true"
        :close-on-click-modal="false"
        width="70%">
        注：此操作会记录在《样品接收与分发记录》，并确认以下说明
        <el-row style="margin-top: 5px;">
          <el-col :span="24">
            <el-card>
              <el-form label-width="100px">
                <el-form-item>
                  确定分发<span class="font-highlight">【{{dataForm.checkList.checkTypeName}}】{{dataForm.checkList.productName}}（物料编码：{{dataForm.checkList.batchNum}}，规格：<span v-html="dataForm.checkList.productSpec"></span><span v-if="dataForm.checkList.productPackSpec != null">，包装规格：{{dataForm.checkList.productPackSpec}}</span>）</span>给以下小组：
                </el-form-item>
                <el-col :offset="5" :span="15">
                  <el-form-item label="分发日期：">
                    <el-date-picker
                      :disabled="true"
                      v-model="dataForm.dispense.dispenseDate"
                      align="right"
                      type="date"
                      placeholder="分发日期"
                      :clearable="false"
                      style="width: 100%;"
                      format="yyyy 年 MM 月 dd 日"
                      value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :offset="5" :span="15">
                  <el-form-item label="剩余量：">
                    <span :style="{'color': dataForm.receive.surplusQuantity >= 0 ? '#409EFF' : '#F56C6C','font-size': '20px'}">{{ dataForm.receive.surplusQuantity }}</span>
                    &nbsp;&nbsp;&nbsp;
                    <span style="font-size: 20px">{{ dataForm.receive.receiveUnitName }}</span>
                  </el-form-item>
                </el-col>
                <el-col :offset="5" :span="15">
                  <el-form-item v-for="(item, index) in dataForm.groupGets" :key="index" :label="item.inspectionGroupName + '：'" :prop="'groupGets.' + index + 'groupGetQuantity'">
                    <el-input placeholder="分发量" v-model="item.groupGetQuantity" @change="changeGroupGetQuantity(item)">
                      <template slot="append">{{ item.groupGetUnitName }}</template>
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-form>
            </el-card>
          </el-col>
        </el-row>

        <span slot="footer" class="dialog-footer">
          <el-button @click="closeDispense">取 消</el-button>
          <el-button type="primary" class="pan-btn primary-btn" :loading="submitDising" @click="submitDis">确 定</el-button>
        </span>
      </el-dialog>
  </el-drawer>
</template>

<script>
  import { mapGetters } from 'vuex'
  import { isBlank,parseTime,unique,arrEq,lineToHump } from '@/common/js/utils'
  import { isPositiveNumber } from '@/common/js/validate'
  import { CODE_OK } from '@/common/js/config'
  import {
    getCheckInfo,
    returnCheck,
    cancelCheck,
    saveHalf,
    updateItem,
    recallVerdict,
    recallPass,
    getUpdateItemInfo,
    addItemAfterDispense,
    deleteItemAfterDispense,
    updateCheckItemGroup,
    getYsQuantityInfo,
    getVersion,
    updateListContentForUpdateMode,
    updateYfbContentForUpdateMode,
    updateZcContentForUpdateMode,
    getUnitList,
    getCheckPurposeList,
    getProcedureList,
    getWorkshopList
  } from '@/api/check'
  import { getProductPackSpecsByProductId } from '@/api/product'
  import { getSupplierList } from "@/api/supplier"
  import { getManufacturerList } from "@/api/manufacturer"
  import { getStandardByProductId,getStandardById } from '@/api/standard'
  import { getGroupList } from '@/api/inspection'
  import Calc from 'calculatorjs'
  import Print from '@/views/modules/print'
  import ChangeStandard from '@/views/modules/common/change-standard'
  export default {
    components: {
      Print,
      ChangeStandard
    },
    filters: {
      titleFilter(checkTypeId) {
        const titleMap = {
          1: '原料请验单',
          2: '辅料请验单',
          3: '包材请验单',
          4: '中间品请验单',
          5: '成品请验单',
          6: '稳定性考察请验单',
          9: '其他请验单'
        }
        return titleMap[checkTypeId]
      },
      showTime(time,flag) {
        if (flag == 1) {
          return time.substring(0,7)
        }else{
          return time.split(' ')[0]
        }
      }
    },
    data() {
      return {
        size: '30%',
        visible: false,
        printVisible: false,
        reportVisible: false,
        standardDrawerVisible: false,
        dataListLoading: false,
        returnVisible: false,
        submitingReturn: false,
        dispenseVisible: false,
        allItems: [],
        versions: [],
        dataForm: {
          content: null,
          currentStatus: null,
          checkList: '',
          standard: '',
          yfbList: '',
          zcList: {
            workshopName: ''
          },
          wkList: '',
          ysList: '',
          checkReturn: '',
          items: [],
          itemNames: '',
          receive: '',
          dispense: '',
          groupGets: []
        },
        statusList: [],
        grandDataForm: {},
        editing: false,
        editGrouping: false,
        selectionList: [],
        addItems: [],
        addItemsVisible: false,
        deleteItems: false,
        deleteItemsVisible: false,
        remainItems: [],
        submitAdding: false,
        submitDeleteing: false,
        submitDising: false,
        groupList: [],
        changeStandardVisible: false,
        isUpdateMode: false,
        baseInfo: {
          have: false
        },
        yfbInfo: {
          have: false
        },
        zcInfo: {
          have: false
        },
        // prop
        // list:
        yfbProductPackSpecInput: false,
        zcProductPackSpecInput: false,
        yfbBatchNumInput: false,
        zcBatchNumInput: false,
        registCheckDateInput: false,
        // yfb:
        yfbReMarkInput:false,
        originalBatchInput: false,
        grossQuantityInput: false,
        grossPieceInput: false,
        deliveryAndBuyQuantityInput: false,
        supplierNameInput: false,
        manufacturerNameInput: false,
        yfbProductionDateInput: false,
        yfbValidityDateInput: false,
        reinspectDateInput: false,
        // zc:
        batchQuantityInput: false,
        productionQuantityInput: false,
        procedureNameInput: false,
        workshopNameInput: false,
        zcProductionDateInput: false,
        zcValidityDateInput: false
      }
    },
    props: ["childDataForm"],
    created() {
      if (!isBlank(this.childDataForm)) {
        this.dataForm.currentStatus = this.childDataForm.currentStatus
        this.dataForm.checkList = this.childDataForm.info
        this.getInfo()
      	this.visible = true
      }
    },
    mounted() {
      this.$nextTick(() => {
        const body = document.querySelector("body")
        if (body.append) {
          body.append(this.$el)
        } else {
          body.appendChild(this.$el)
        }
      })
    },
    computed: {
      yfb() {
        if (this.dataForm.checkList.checkTypeName == '原料'
        || this.dataForm.checkList.checkTypeName == '独立请验'
        || this.dataForm.checkList.checkTypeName == '辅料'
        || this.dataForm.checkList.checkTypeName == '包材'
        || this.dataForm.checkList.checkTypeName == '其他') {
          return true
        }
        return false
      },
      zc() {
        if (this.dataForm.checkList.checkTypeName == '中间品'
        || this.dataForm.checkList.checkTypeName == '成品') {
          return true
        }
        return false
      },
      z() {
        return this.dataForm.checkList.checkTypeName == '中间品'
      },
      c() {
        return this.dataForm.checkList.checkTypeName == '成品'
      },
      wk() {
        return this.dataForm.checkList.checkTypeName == '稳定性考察'
      },
      ys() {
        return this.dataForm.checkList.checkTypeName == '制药用水/纯蒸汽'
      },
      other() {
        return this.dataForm.checkList.checkTypeName == '独立请验'
      },
      ...mapGetters([
         'userInfo'
      ]),
      returnBtn() {
        //进入页面为请验后分样前菜单、请验单状态为分样之前且非待处理状态，允许退回
        return this.dataForm.currentStatus > 0 && this.dataForm.currentStatus < 4 && this.dataForm.checkList.status < 4 && this.dataForm.checkList.status != 0
      },
      cancelBtn() {
        //发起人为当前用户、进入页面为请验菜单,请验单状态为报告之前，允许作废
        return this.dataForm.checkList.registCheckUserId == this.userInfo.userId && this.dataForm.currentStatus == 0 && this.dataForm.checkList.status < 7
      },
      printBtn() {
        //中间品(注射剂，无菌)、进入页面为结论菜单、请验单状态为检验中或待结论状态，允许半路打印
        return this.dataForm.currentStatus == 6 && (this.dataForm.checkList.status == 4 || this.dataForm.checkList.status == 6) && this.dataForm.checkList.checkTypeName == '中间品' && (this.dataForm.zcList.workshopName.indexOf("注射剂") > -1 || this.dataForm.zcList.workshopName.indexOf("无菌") > -1)
      },
      recallBtn() {
        //进入页面为结论菜单、非合并，请验单状态为待放行(成品,原辅包其他)或者已完成(中间品，稳考，水)(此页为原辅包，中间品，稳考界面,水)，允许撤回结论
        if (this.dataForm.currentStatus == 6 && this.dataForm.checkList.isMerge == 1) {
          if (this.yfb) {
            return this.dataForm.checkList.status == 7
          }
          if (this.z || this.wk || this.ys) {
            return this.dataForm.checkList.status == 11
          }
        }
        return false
      },
      changeStandardBtn() {
        //进入页面为结论菜单、请验单状态为未结论之前，允许修改标准
        return this.dataForm.checkList.isTest == 0
          && this.dataForm.currentStatus == 6
          && !this.c
          && this.dataForm.checkList.status <= 6
      },
      recallPassBtn() {
        //进入页面为放行菜单、请验单状态为放行之后（原辅包(此页)，成品），允许撤回放行
        return this.dataForm.currentStatus == 7
          && this.yfb
          && (this.dataForm.checkList.status == 8 || this.dataForm.checkList.status == 11)
      },
      showStandardBtn() {
        return this.dataForm.checkList.isTest == 0
      },
      editBtn() {
        //进入页面为收分样，请验单状态为待收样，待分样，允许修改检验项
        return this.dataForm.currentStatus == 2 && (this.dataForm.checkList.status == 2 || this.dataForm.checkList.status == 3)
      },
      updateBtn() {
        //进入页面为结论菜单、请验单状态为检验中、等待中、待结论状态、待收报告状态(不允许操作但能看到，撤销后允许操作)，允许增加或者删除检验项
        return this.dataForm.currentStatus == 6 && (this.dataForm.checkList.status == 4 || this.dataForm.checkList.status == 5 || this.dataForm.checkList.status == 6 || this.dataForm.checkList.status == 10)
      },
      showUpdateModeBtn() {
        // 进入页面为请验菜单、状态为任何状态，本人，允许修改请验信息
        return this.dataForm.currentStatus == 0 && this.dataForm.checkList.registCheckUserId == this.userInfo.userId
      }
    },
    methods: {
      dateTypeFilter(flag) {
        return flag == 1 ? 'month' : 'date'
      },
      dateFormatFilter(flag) {
        return flag == 1 ? 'yyyy年MM月' : 'yyyy年MM月dd日'
      },
      searchSupplier(query) {
        this.$set(this.yfbInfo,'supplierList',[])
        if (!isBlank(query)) {
          const params = {
          	page: 1,
            limit: 10,
          	supplierName: query
          }
          getSupplierList(params).then(res => {
            if (res.code === CODE_OK) {
              this.yfbInfo.supplierList = res.page.list
            }else{
              this.$message.error(res.msg)
            }
          })
        }
      },
      searchManufacturer(query) {
        this.$set(this.yfbInfo,'manufacturerList',[])
        if (!isBlank(query)) {
          const params = {
            page: 1,
            limit: 10,
            manufacturerName: query
          }
          getManufacturerList(params).then(res => {
            if (res.code === CODE_OK) {
              this.yfbInfo.manufacturerList = res.page.list
            }else{
              this.$message.error(res.msg)
            }
          })
        }
      },
      getYfbInfo() {
        const params = {
          checkTypeId: 1,
          printVersion: this.dataForm.checkList.printCheckVersion
        }
        getCheckPurposeList(params).then(res => {
          if (res.code === CODE_OK) {
            this.$set(this.yfbInfo, 'checkPurposeList', res.list)
          }else{
            this.$message.error(res.msg)
          }
        })
        this.yfbInfo.have = true
      },
      getZcInfo() {
        getProcedureList().then(res => {
          if (res.code === CODE_OK) {
            this.$set(this.zcInfo, 'procedureList', res.list)
          }else{
            this.$message.error(res.msg)
          }
        })
        getWorkshopList().then(res => {
          if (res.code === CODE_OK) {
            this.$set(this.zcInfo, 'workshopList', res.list)
          }else{
            this.$message.error(res.msg)
          }
        })
        const params = {
          productId: this.dataForm.checkList.productId
        }
        getProductPackSpecsByProductId(params).then(res => {
          if (res.code === CODE_OK) {
            this.$set(this.zcInfo, 'productPackSpecList', res.productPackSpecs)
            if (isBlank(res.productPackSpecs)) {
              this.$message.error("请联系QA管理员(肖慧)添加此货品的包装规格")
            }
          }else{
            this.$message.error(res.msg)
          }
        })
        this.zcInfo.have = true
      },
      getBaseInfo() {
        getUnitList().then(res => {
          if (res.code === CODE_OK) {
            this.$set(this.baseInfo, 'unitList', res.list)
          }else{
            this.$message.error(res.msg)
          }
        })
        this.baseInfo.have = true
      },
      updateModeInit(){
        this.getBaseInfo()
        if (this.yfb && !this.yfbInfo.have) {
          this.getYfbInfo()
        }else if(this.zc && !this.zcInfo.have) {
          this.getZcInfo()
        }else if(this.other){
          alert("修改独立请验信息")
        }
        this.isUpdateMode = true
      },
      updateMode() {
        this.$confirm('修改请验信息并告知相关人员?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$alert('请点击你想要修改的信息(黄色区域),修改后不可撤回,修改成功后会告知相关人员')
          this.updateModeInit()
        }).catch(() => {
          this.isUpdateMode = false
        })
      },
      updateModeExit() {
        this.isUpdateMode = false
      },
      openSet(k1, k2) {
        if (this.isUpdateMode) {
          this[this.propFilter(k1)] = true
          if (k2 != undefined) {
            this[this.propFilter(k2)] = true
          }
        }
      },
      openSet2(prop) {
        if (this.isUpdateMode) {
          this[prop] = true
        }
      },
      propFilter(k) {
        return lineToHump(k) + 'Input'
      },
      //修改模式修改方法
      setListContent(k, v, r, idk, idv, prop) {
        const data = {
          key: k,
          value: v,
          idKey: idk || null,
          idValue: idv || null,
          remark: r,
          checkId: this.dataForm.checkList.checkId
        }
        updateListContentForUpdateMode(data).then(res => {
          if (res.code === CODE_OK) {
            if (isBlank(prop)) {
              this[this.propFilter(k)] = false
            }else{
              this[prop] = false
            }
            this.$message.success('修改成功')
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      setYfbContent(k, v, r, idk, idv, prop) {
        const data = {
          key: k,
          value: v,
          idKey: idk || null,
          idValue: idv || null,
          remark: r,
          checkId: this.dataForm.checkList.checkId,
          checkYfbId: this.dataForm.yfbList.checkYfbId
        }
        updateYfbContentForUpdateMode(data).then(res => {
          if (res.code === CODE_OK) {
            if (isBlank(prop)) {
              this[this.propFilter(k)] = false
            }else{
              this[prop] = false
            }
            this.$message.success('修改成功')
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      setYfbContentAndId(k, v, r, arr, arrProp) {
        // 通过name找id
        let idk = k.replace('name', 'id')
        let idProp = lineToHump(idk)
        this.dataForm.yfbList[idProp] = arr.find(u => u[arrProp] == v)[arrProp.replace('Name', 'Id')]
        let idv = this.dataForm.yfbList[idProp]
        this.setYfbContent(k, v, r, idk, idv)
      },
      setZcContentAndId(k, v, r, arr, arrProp) {
        // 通过name找id
        let idk = k.replace('name', 'id')
        let idProp = lineToHump(idk)
        this.dataForm.zcList[idProp] = arr.find(u => u[arrProp] == v)[arrProp.replace('Name', 'Id')]
        let idv = this.dataForm.zcList[idProp]
        this.setZcContent(k, v, r, idk, idv)
      },
      setZcContent(k, v, r, idk, idv, prop) {
        const data = {
          key: k,
          value: v,
          idKey: idk || null,
          idValue: idv || null,
          remark: r,
          checkId: this.dataForm.checkList.checkId,
          checkZcId: this.dataForm.zcList.checkZcId
        }
        updateZcContentForUpdateMode(data).then(res => {
          if (res.code === CODE_OK) {
            if (isBlank(prop)) {
              this[this.propFilter(k)] = false
            }else{
              this[prop] = false
            }
            this.$message.success('修改成功')
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      goOtherRoute(name,id) {
        this.handleClose()
        this.$nextTick(() => {
          this.$router.push({
          	name: name,
            params: {
              id: id
            }
          })
        })
      },
      changeItemGroup(row) {
        for (let g of this.groupList) {
          if (g.inspectionGroupName == row.inspectionGroupName) {
            row.inspectionGroupId = g.inspectionGroupId
            break
          }
        }
        const data = {
          checkItemId: row.checkItemId,
          inspectionGroupId: row.inspectionGroupId,
          inspectionGroupName: row.inspectionGroupName
        }
        updateCheckItemGroup(data).then(res => {
          if (res.code === CODE_OK) {
            this.$message.success('修改成功')
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      deleteItem() {
        if (this.dataForm.checkList.status == 10) {
          this.$message.error('请撤销结论后再修改检验项')
          return
        }
        if (this.dataForm.items.length == 1) {
          this.$message.error('只有一个检验项无法删除')
          return
        }
        this.deleteItems = JSON.parse(JSON.stringify(this.dataForm.items))
        this.getUpdateItemInfo('delete')
      },
      deleteItemAfterDispense(data) {
        deleteItemAfterDispense(data).then(res => {
          if (res.code === CODE_OK) {
            this.$message({
              message: '删除成功',
              type: 'success',
              duration: 500,
              onClose: () => {
                this.$emit('refreshData')
                this.handleClose()
              }
            })
          }else{
            this.$message.error(res.msg)
            this.submitDeleteing = false
          }
        })
      },
      submitDeleteItems() {
        this.submitDeleteing = true
        if (this.selectionList.length == 0) {
          this.$message.error('若删除，请选择至少一个项目')
          return
        }
        let selectIds = this.selectionList.map(item => {return item.checkItemId})
        this.remainItems = this.dataForm.items.filter(i => {return selectIds.indexOf(i.checkItemId) == -1})
        let remainGroupIds = unique(this.remainItems.map(i => {return i.inspectionGroupId}))
        let allGroupIds = this.dataForm.groupGets.filter(item => {
          return item.inspectionGroupName != '稳考室' && item.inspectionGroupName != '留样室'
        }).map(i => {return i.inspectionGroupId})
        let selectGroups = []
        selectGroups.push({
          inspectionGroupId: this.selectionList[0].inspectionGroupId,
          inspectionGroupName: this.selectionList[0].inspectionGroupName
        })
        for (let i=1,j=this.selectionList.length; i<j; i++) {
          for (let x=0,y=selectGroups.length; x<y; x++) {
            if (this.selectionList[i].inspectionGroupId == selectGroups[x].inspectionGroupId) {
              break
            }else if(x==y-1) {
              selectGroups.push({
                inspectionGroupId: this.selectionList[i].inspectionGroupId,
                inspectionGroupName: this.selectionList[i].inspectionGroupName
              })
            }
          }
        }
        const data = {
          list: this.dataForm.checkList,
          checkStandardId: this.dataForm.standard.checkStandardId,
          itemIds: selectIds, //delete
          groupIds: selectGroups.map(g => {return g.inspectionGroupId})
        }
        if (arrEq(allGroupIds, remainGroupIds)) {
          //未改变组
          this.deleteItemAfterDispense(data)
        }else{
          //改变组
          this.$confirm('正常检验时，分发后的各小组至少需要留一个检验项目，当出现不合格项目时，为终止此次检验(不会改变分样台账)，是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(async () => {
            this.deleteItemAfterDispense(data)
          }).catch(() => {
            this.submitDeleteing = false
            return
          })
        }
      },
      groupFinish(groupId) {
        for (let item of this.remainItems) {
          if (item.itemStatus == 1 && item.inspectionGroupId == groupId) {
            return false
          }
        }
        return true
      },
      changeGroupStatusOk(groupId) {
        let allGroupFinish = true
        for (let i=0,j=this.dataForm.groupGets.length; i<j; i++) {
          if (this.dataForm.groupGets[i].inspectGroupIds == groupId) {
            this.dataForm.groupGets[i].groupStatus = 3
            continue
          }
          if (this.dataForm.groupGets[i].groupStatus != 3 && this.dataForm.groupGets[i].inspectionGroupName != '留样室' && this.dataForm.groupGets[i].inspectionGroupName != '稳考室') {
            allGroupFinish = false
          }
        }
        return allGroupFinish
      },
      closeDeleteItems() {
        this.deleteItemsVisible = false
      },
      submitDis() {
        if (this.dataForm.receive.surplusQuantity < 0) {
          this.$message.error("剩余量不够分了哦")
          return
        }else{
          for (let item of this.dataForm.groupGets) {
            if (isBlank(item.groupGetQuantity) && item.inspectionGroupName != '留样室' && item.inspectionGroupName != '稳考室') {
              this.$message.error("所有检验组的分发量均不能为空")
              return
            }
          }
        }
        this.dataForm.checkList.status = 4
        for (let i=0,j=this.dataForm.groupGets.length; i<j; i++) {
          if (this.dataForm.groupGets[i].checkGroupGetId == null) {
            this.dataForm.checkList.inspectGroupIds = this.dataForm.checkList.inspectGroupIds + ',' + this.dataForm.groupGets[i].inspectionGroupId
            this.dataForm.checkList.inspectGroupNames = this.dataForm.checkList.inspectGroupNames + ',' + this.dataForm.groupGets[i].inspectionGroupName
          }
        }
        const data = {
          list: this.dataForm.checkList, //update
          checkStandardId: this.dataForm.standard.checkStandardId,  //aux
          items: this.selectionList, //insert
          receive: this.dataForm.receive, //update
          dispense: this.dataForm.dispense,  //update
          groupGets: this.dataForm.groupGets //update
        }
        this.submitDising = true
        this.addItemAfterDispense(data)
      },
      changeGroupGetQuantity(item) {
        if (item.groupGetQuantity == 0) {
          this.$message.error("分发量不能为0，若此小组多余，请查看检验项是否配置正确")
          let index = this.dataForm.groupGets.indexOf(item)
          this.dataForm.groupGets[index].groupGetQuantity = null
          return
        }
        if(!isPositiveNumber(item.groupGetQuantity) && !isBlank(item.groupGetQuantity)){
          this.$message.error("请输入正数")
          let index = this.dataForm.groupGets.indexOf(item)
          this.dataForm.groupGets[index].groupGetQuantity = null
          return
        }
        this.computeSurplus()
      },
      computeSurplus() {
        this.dataForm.dispense.dispenseQuantity = 0
        for (let i=0,j=this.dataForm.groupGets.length; i<j; i++) {
          if (!isBlank(this.dataForm.groupGets[i].groupGetQuantity)) {
            this.dataForm.dispense.dispenseQuantity = Calc.add(this.dataForm.dispense.dispenseQuantity,this.dataForm.groupGets[i].groupGetQuantity)
          }
        }
        this.dataForm.receive.surplusQuantity = Calc.sub(this.dataForm.receive.receiveQuantity,this.dataForm.dispense.dispenseQuantity)
      },
      closeDispense() {
        this.dispenseVisible = false
        this.getUpdateItemInfo('add')
      },
      getUpdateItemInfo(flag) {
        const params1 = {
          checkId: this.dataForm.checkList.checkId
        }
        getUpdateItemInfo(params1).then(res => {
          if (res.code === CODE_OK) {
            this.dataForm.receive = res.info.receive
            this.dataForm.dispense = res.info.dispense
            this.dataForm.groupGets = res.info.groupGets
            if (flag == 'add') {
              this.addItemsVisible = true
            }else{
              this.deleteItemsVisible = true
            }
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      closeAddItems() {
        this.addItemsVisible = false
        this.selectionList = []
      },
      getGroupNameById(id) {
        for (let i=0,j=this.selectionList.length; i<j; i++) {
          if (this.selectionList[i].inspectionGroupId == id) {
            return this.selectionList[i].inspectionGroupName
          }
        }
      },
      submitAddItems() {
        let oldGroupIds = unique(this.dataForm.groupGets.map(g => {
          return g.inspectionGroupId
        }))
        let newGroupIds = unique(this.selectionList.map(g => {
          return g.inspectionGroupId
        }))
        let addGroup = []
        for (let i=0,j=newGroupIds.length; i<j; i++) {
          for (let x=0,y=oldGroupIds.length; x<y; x++) {
            if (newGroupIds[i] === oldGroupIds[x]) {
              break
            }else{
              if (x==y-1) {
                addGroup.push({
                  checkGroupGetId: null,
                  checkDispenseId: this.dataForm.dispense.checkDispenseId,
                  inspectionGroupId: newGroupIds[i],
                  inspectionGroupName: this.getGroupNameById(newGroupIds[i]),
                  groupGetQuantity: null,
                  groupGetUnitId: this.dataForm.groupGets[0].groupGetUnitId,
                  groupGetUnitName: this.dataForm.groupGets[0].groupGetUnitName,
                  groupGetUserId: null,
                  groupGetUserName: null,
                  groupGetDate: null,
                  groupStatus: 1
                })
              }
            }
          }
        }
        this.dataForm.groupGets = this.dataForm.groupGets.map(g => {
          if (newGroupIds.indexOf(g.inspectionGroupId) > -1 && g.groupStatus == 3) {
            g.groupStatus = 2
          }
          return g
        })
        if (addGroup.length > 0) {
          //添加小组后添加item
          // if (this.dataForm.receive.surplusQuantity > 0) {
            this.dataForm.groupGets = this.dataForm.groupGets.concat(addGroup)
            this.dispenseVisible = true
          // }else{
            // this.$message.error('当前批次货品分发后无剩余量，已经不足以分发给新添加的检验小组，请检查后再试')

          // }
        }else{
          //直接添加item,修改groupStatus为3的groupGets为2
          this.dataForm.checkList.status = 4
          const data = {
            list: this.dataForm.checkList, //update
            checkStandardId: this.dataForm.standard.checkStandardId,  //aux
            items: this.selectionList, //insert
            groupGets: this.dataForm.groupGets //update
          }
          this.submitAdding = true
          this.addItemAfterDispense(data)
        }
      },
      addItemAfterDispense(data) {
        addItemAfterDispense(data).then(res => {
          if (res.code === CODE_OK) {
            this.$message.success('添加成功，请提醒小组及时填写')
            this.closeAddItems()
            this.$emit('refreshData')
            this.handleClose()
          }else{
            this.$message.error(res.msg)
            this.submitAdding = false
            this.submitDising = false
          }
        })
      },
      addItem() {
        if (this.dataForm.checkList.status == 10) {
          this.$message.error('请撤销结论后再修改检验项')
          return
        }
        const params = {
          standardId: this.dataForm.standard.insideInspectionStandardId,
          productId: this.dataForm.checkList.productId
        }
        getStandardByProductId(params).then(res => {
          if (res.code === CODE_OK) {
            this.addItems = []
            for (let i=0,j=res.standard.items.length; i<j; i++) {
              for (let x=0,y=this.dataForm.items.length; x<y; x++) {
                if (res.standard.items[i].inspectionItemId == this.dataForm.items[x].inspectionItemId) {
                  break
                }else if(x==y-1){
                  this.addItems.push(res.standard.items[i])
                }
              }
            }
            if (this.addItems.length == 0) {
              this.$message.error("当前没有可增加的新的检验项，请先联系QC管理员(刘威)添加检验项，或者您已经删除了此单此标准的所有项目，那么请联系系统管理员")
            }else{
              this.getUpdateItemInfo('add')
            }
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      getInfo() {
        if (this.yfb) {
          this.dataForm.content = 'yfb'
        }else if(this.zc){
          this.dataForm.content = 'zc'
        }else if(this.wk){
          this.dataForm.content = 'wk'
        }else if(this.ys) {
          this.dataForm.content = 'ys'
        }else if(this.other){
          this.dataForm.content = 'other'
        }
        const params = {
          content: this.dataForm.content,
          checkId: this.dataForm.checkList.checkId
        }
        getCheckInfo(params).then(res => {
          if (res.code === CODE_OK) {
          	this.dataForm.yfbList = res.info.yfbList
          	this.dataForm.zcList = res.info.zcList
            this.dataForm.wkList = res.info.wkList
            this.dataForm.ysList = res.info.ysList
            if (this.ys) {
              getYsQuantityInfo(params).then(res => {
                if (res.code === CODE_OK) {
                  this.$set(this.dataForm.ysList,'wqInfo',res.info)
                  this.$set(this.dataForm.ysList,'wgInfo',res.cgys.map(cgy => {return cgy.waterGetName}).join('、'))
                }else{
                  this.$message.error(res.msg)
                  this.close()
                }
              })
            }
            this.allItems = res.info.items
            this.dataForm.items = res.info.items
            this.dataForm.checkReturn = res.info.checkReturn
            if (this.showStandardBtn) {
              this.dataForm.standard = res.info.standard
              if(this.dataForm.items != null){
                this.dataForm.itemNames = this.dataForm.items.map(item => {
                  return item.inspectionItemName
                })
                this.dataForm.itemNames = this.dataForm.itemNames.join('、')
              }
            }
          }else{
          	this.$message.error(res.msg)
          }
        })
      },
      recall() {
        //撤回结论
        const data = {
          checkId: this.dataForm.checkList.checkId
        }
        recallVerdict(data).then(res => {
          if (res.code === CODE_OK) {
            this.$message({
              message: '提交成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.$emit('refreshData')
                this.handleClose()
              }
            })
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      changeStandard() {
        this.grandDataForm = {
          checkMergeId: this.dataForm.checkList.checkMergeId,
          productId: this.dataForm.checkList.productId,
          checkTypeId: this.dataForm.checkList.checkTypeId
        }
        this.changeStandardVisible = true
      },
      recallPass() {
        //测回放行
        const data = {
          checkMergeId: this.dataForm.checkList.checkMergeId
        }
        recallPass(data).then(res => {
          if (res.code === CODE_OK) {
            this.$message({
              message: '提交成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.$emit('refreshData')
                this.handleClose()
              }
            })
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      print() {
        //已经打印过
        if (this.dataForm.checkList.isHalf == 0) {
          this.showReport()
        }else{
          //未打印过
          this.$set(this.grandDataForm,'halfReportDate', parseTime(new Date()))
          // 注射剂车间或者无菌车间,加以上项目,否则 不全检加,全检不加
          let wname = this.dataForm.zcList.workshopName
          let yishangxiangmu = wname.indexOf("注射剂") > -1 || wname.indexOf("无菌") > -1 ? '以上项目'
           : this.dataForm.checkList.isAllTest == 0 ? '' : '以上项目'
          let tempVerdict = "本品按" + this.dataForm.standard.accordingToInside + "检验" + yishangxiangmu + ",结果符合规定。"
          this.$set(this.grandDataForm,'halfVerdict', tempVerdict)
          this.getVersions()
        }
      },
      getVersions() {
        const params = {
          checkTypeId:  this.dataForm.checkList.checkTypeId,
          printClassify:  '报告书'
        }
        this.$set(this.grandDataForm, 'printReportVersion', null)
        getVersion(params).then(res => {
          if (res.code === CODE_OK) {
            this.versions = res.list.map(v => {
              if (v.isCurrent == 0) {
                this.$set(v, 'title', v.recordNum + '-' + v.versionNum + '(当前版本)')
                this.grandDataForm.printReportVersion = v.versionNum
              }else{
                this.$set(v, 'title', v.recordNum + '-' + versionNum)
              }
              return v
            })
            this.printVisible = !this.printVisible
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      closePrint() {
        this.printVisible = !this.printVisible
      },
      showReport() {
        if (this.dataForm.checkList.isHalf == 0) {
          this.openReport()
        }else{
          if (isBlank(this.grandDataForm.halfReportDate)) {
            this.$message.error("报告日期不能为空")
            return
          }
          if (isBlank(this.grandDataForm.halfVerdict)) {
            this.$message.error("第一次结论不能为空")
            return
          }
          if (isBlank(this.grandDataForm.printReportVersion)) {
            this.$message.error("报告书版本号不能为空")
            return
          }
          //未打印过，存入数据库
          const data = {
            checkId: this.dataForm.checkList.checkId,
            halfReportDate: this.grandDataForm.halfReportDate,
            halfVerdict: this.grandDataForm.halfVerdict,
            printReportVersion: this.grandDataForm.printReportVersion
          }
          this.dataForm.checkList.printReportVersion = this.grandDataForm.printReportVersion
          saveHalf(data).then(res => {
            if (res.code === CODE_OK) {
              this.openReport()
            }else{
              this.$message.error(res.msg)
            }
          })
        }
      },
      openReport() {
        this.dataForm.checkList.reportDate = this.dataForm.checkList.isHalf == null ?
          JSON.parse(JSON.stringify(this.grandDataForm.halfReportDate)) :
          JSON.parse(JSON.stringify(this.dataForm.checkList.halfReportDate))
        this.grandDataForm = JSON.parse(JSON.stringify(this.dataForm.checkList))
        this.$set(this.grandDataForm, 'unfinish', true)
        this.$set(this.grandDataForm, 'printClassify', '报告书')
        this.reportVisible = !this.reportVisible
      },
      close(prop, refresh) {
        this.grandDataForm = {}
        if (refresh == 'refresh') {
          this.$emit('refreshData')
        }
        this[prop] = false
      },
      updateItem() {
        if (this.editing) {
          if (this.selectionList.length == 0) {
            this.$message.error("请选择至少一个检验项")
            return
          }
          //如果是用水，那么需要判断检验项目中的小组，和检验类别中的小组比较
          if (this.ys) {
            let itemGroupIds = unique(this.selectionList.map(v => {return v.inspectionGroupId}))
            let wqGroupIds = unique(this.dataForm.ysList.wgqs.map(v => {return v.inspectionGroupId}))
            if (!arrEq(itemGroupIds, wqGroupIds)) {
              let itemGroupNames = unique(this.selectionList.map(v => {return v.inspectionGroupName}))
              let wqGroupNames = unique(this.dataForm.ysList.wgqs.map(v => {return v.inspectionGroupName}))
              let msg = '检验项目中的小组有:' + itemGroupNames + ',检验类别中的小组有:' + wqGroupNames + ',请联系标准管理员(刘威)验证检验项目所属小组是否正确。'
              this.$message({
                message: msg,
                type: 'error',
                duration: 3500
              })
              return
            }
          }
          const data = {
            isAllTest: this.selectionList.length == this.allItems.length ? 0 : 1,
            list: this.dataForm.checkList,
            checkStandardId: this.dataForm.standard.checkStandardId,
            items: this.selectionList
          }
          updateItem(data).then(res => {
            if (res.code === CODE_OK) {
              this.dataForm.checkList.isAllTest = data.isAllTest
              this.getInfo()
              this.editing = false
              this.$message.success("修改成功")
            }else{
              this.$message.error(res.msg)
            }
          })
        }else{
          this.editGrouping = false
        }
      },
      editItem() {
        if (this.dataForm.standard.insideInspectionStandardId == null) {
          this.$message.error("此单属于相容性试验，无法删除和增加检验项目")
          return
        }
        const params = {
          standardId: this.dataForm.standard.insideInspectionStandardId
        }
        getStandardById(params).then(res => {
          if (res.code === CODE_OK) {
            this.allItems = res.standard.items
            let checkedItems = this.dataForm.items
            if (checkedItems.length != 0) {
              for (let i=0,j=checkedItems.length; i<j; i++) {
                for (let x=0,y=this.allItems.length; x<y; x++) {
                  if (checkedItems[i].inspectionItemId == this.allItems[x].inspectionItemId) {
                    this.$nextTick(() => {
                      this.checked(x)
                    })
                  }
                }
              }
            }
          }else{
            this.$message.error(res.msg)
          }
        })
        this.editing = !this.editing
      },
      editGroup() {
        const params = {
          page: 1,
          limit: 9999999
        }
        getGroupList(params).then(res => {
        	if (res.code === CODE_OK) {
        		this.groupList = res.page.list.filter(g => {
              return g.inspectionGroupId != 1 && g.inspectionGroupId != 2
            })
        	}else{
            this.$message.error(res.msg)
          }
        })
        this.editGrouping = true
      },
      closeEdit() {
        if (this.editing) {
          this.editing = false
          this.allItems = JSON.parse(JSON.stringify(this.dataForm.items))
        }else{
          this.editGrouping = false
        }
      },
      checked(index) {
      	this.$refs.dataTable.toggleRowSelection(this.allItems[index],true)
      },
      selectionChange(obj) {
      	this.selectionList = obj
      },
      handleCurrentChange(row, event, column){
        this.$refs.dataTable.toggleRowSelection(row,false)
      },
      showStandardDrawer() {
        this.standardDrawerVisible = !this.standardDrawerVisible
      },
      closeStandardDrawer(done) {
        this.editing = false
        done()
      },
      showReturn() {
        this.returnVisible = !this.returnVisible
        this.returnInit()
      },
      cancel() {
        this.$confirm('确认将此单作废,若下了结论也将撤回？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          const data = {
            checkId: this.dataForm.checkList.checkId,
            content: this.dataForm.content
          }
          cancelCheck(data).then(res => {
            if (res.code === CODE_OK) {
              this.$message({
                message: '提交成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.$emit('refreshData')
                  this.handleClose()
                }
              })
            }else{
              this.$message.error(res.msg)
            }
          })
        })
      },
      returnInit() {
        this.dataForm.checkReturn.checkId = this.dataForm.checkList.checkId
        this.dataForm.checkReturn.returnTime = parseTime(new Date())
        this.dataForm.checkReturn.fromUserId = this.userInfo.userId
        this.dataForm.checkReturn.fromUserName = this.userInfo.name
        this.dataForm.checkReturn.fromStatus = this.dataForm.checkList.status
        this.dataForm.checkReturn.handleStatus = 0
        if (this.statusList.length == 0) {
          let status = this.dataForm.checkList.status
          switch (status){
            //目前不开放退回至取样以后的节点,不能要break
            case 4:
              // this.statusList.push({
              //   status: 3,
              //   name: '分样',
              //   userId: this.dataForm.checkList.dispenseUserId,
              //   userName: this.dataForm.checkList.dispenseUserName
              // })
            case 3:
              // this.statusList.push({
              //   status: 2,
              //   name: '收样',
              //   userId: this.dataForm.checkList.receiveUserId,
              //   userName: this.dataForm.checkList.receiveUserName
              // })
            case 2:
              if (!this.ys) {
                this.statusList.push({
                  status: 1,
                  name: '取样',
                  userId: this.dataForm.checkList.getUserId,
                  userName: this.dataForm.checkList.getUserName
                })
              }
            default:
              this.statusList.push({
                status: 0,
                name: '请验',
                userId: this.dataForm.checkList.registCheckUserId,
                userName: this.dataForm.checkList.registCheckUserName
              })
          }
        }
      },
      setToEntity() {
        this.dataForm.checkReturn.toUserId = this.dataForm.checkReturn.toEntity.userId
        this.dataForm.checkReturn.toUserName = this.dataForm.checkReturn.toEntity.userName
        this.dataForm.checkReturn.toStatus = this.dataForm.checkReturn.toEntity.status
      },
      submitReturn() {
        if (isBlank(this.dataForm.checkReturn.returnReason)) {
          this.$message.error("请填写退回理由")
          return
        }else if(isBlank(this.dataForm.checkReturn.returnReason.replace(/(^\s*)|(\s*$)/g, ""))) {
          this.$message.error("请填写退回理由")
          return
        }
        this.submitingReturn = true
        returnCheck(this.dataForm.checkReturn).then(res => {
          if (res.code === CODE_OK) {
            this.$message({
              message: '提交成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.$emit('refreshData')
                this.handleClose()
              }
            })
          }else{
            this.$message.error(res.msg)
            this.submitingReturn = false
          }
        })
      },
      closeReturn() {
        this.returnVisible = !this.returnVisible
      },
      handleClose() {
        this.$emit('close')
        this.visible = false
      }
    }
  }
</script>

<style scoped>
  .color-danger{
    color: #D08585;
  }
  .el-form-item {
    margin-bottom: 0px !important;
  }
  >>> .el-form-item__content {
    line-height: 33px !important;
  }
  .updatemode{
    background-color: gold;
    cursor: pointer
  }
</style>
